<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('延期申请信息')"/>
    <th:block th:include="include :: ztree-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-delay-add" th:object="${delay}">
        <input type="hidden" name="did" th:field="*{did}">
        <div class="col-md-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">转移的任务：</label>
                <div class="col-sm-9">
                    <input type="text" name="tid" class="form-control" th:field="*{info.target}"/>
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">延期到：</label>
            <div class="col-sm-9">
                <div class="input-group date"><span class="input-group-addon"><i class="fa fa-calendar"></i></span>

                    <input type="text" name="ddate" class="form-control" th:field="*{ddate}">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">延期原因：</label>
            <div class="col-sm-9">
                <textarea type="text" name="reason" class="form-control" placeholder="请输入文本"
                          th:field="*{reason}"></textarea>
            </div>
        </div>
</form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: ztree-js"/>
<script type="text/javascript">
    $(function () {
        var url = ctx + "system/menu/roleMenuTreeData";
        var options = {
            id: "menuTrees",
            url: url,
            check: {enable: true},
            expandLevel: 0
        };
        $.tree.init(options);
    });

    $("#form-role-add").validate({
        rules: {
            onkeyup: false,
            roleName: {
                remote: {
                    url: ctx + "system/role/checkRoleNameUnique",
                    type: "post",
                    dataType: "json",
                    data: {
                        "roleName": function () {
                            return $.common.trim($("#roleName").val());
                        }
                    },
                    dataFilter: function (data, type) {
                        return $.validate.unique(data);
                    }
                }
            },
            roleKey: {
                remote: {
                    url: ctx + "system/role/checkRoleKeyUnique",
                    type: "post",
                    dataType: "json",
                    data: {
                        "roleKey": function () {
                            return $.common.trim($("#roleKey").val());
                        }
                    },
                    dataFilter: function (data, type) {
                        return $.validate.unique(data);
                    }
                }
            },
            roleSort: {
                digits: true
            },
        },
        messages: {
            "roleName": {
                remote: "角色名称已经存在"
            },
            "roleKey": {
                remote: "角色权限已经存在"
            }
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            add();
        }
    }

    function add() {
        var target = $("input[name='target']").val();
        var ddate = $("input[name='ddate']").val();
        var reason = $("input[name='reason']").val();
        var uid = $("input[name='uid']").val();
        var vals = $("#form-delay-add").serialize();
        $.ajax({
            cache: true,
            type: "POST",
            url: ctx + "cms/mm/delay/editDelay",
            data: vals/*{
                /!*"roleName": roleName,
                "roleKey": roleKey,
                "roleSort": roleSort,
                "status": status,
                "remark": remark,
                "menuIds": menuIds*!/
            }*/,
            async: false,
            error: function (request) {
                $.modal.alertError("系统错误");
            },
            success: function (data) {
                $.operate.successCallback(data);
            }
        });
    }
</script>
</body>
</html>
